#include "rightclickablebutton.h"
#include <QMouseEvent>
#include <QDebug>

RightClickableButton::RightClickableButton(QWidget *parent) :
    QPushButton(parent)
{
    installEventFilter(this);
    setmarked(false);
}

bool RightClickableButton::eventFilter(QObject *obj, QEvent *event)
{
    if(event->type() == QEvent::MouseButtonRelease)
    {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event);
        if (mouseEvent->button() == Qt::RightButton) {
            emit rightClicked(this->text());
            return false;
        }
    }
    return QPushButton::eventFilter(obj, event);
}

bool RightClickableButton::ismarked()
{
    return marked;
}

void RightClickableButton::setmarked(bool set)
{
    marked = set;
}
